package com.tencent.sr.iris.activity.service.activity;

import com.tencent.sr.iris.activity.domain.event.dto.ActivityDTO;
import com.tencent.sr.iris.activity.domain.event.dto.ActivityTaskDTO;
import com.tencent.sr.iris.activity.interfaces.event.dto.ActivityEventDTO;
import com.tencent.sr.iris.activity.interfaces.request.acticity.QueryEventHandingRecordPageRequest;
import com.tencent.sr.iris.activity.interfaces.request.task.EventRetryRequest;
import com.tencent.sr.iris.activity.interfaces.response.activity.EventHandingRecordResponse;
import com.tencent.sr.iris.activity.repository.entity.TIrisEventHandingRecordDO;
import com.tencent.sr.iris.activity.service.event.vo.IrisEventHandleContext;
import com.tencent.sr.rmall.common.request.PaginationRequest;
import com.tencent.sr.rmall.common.response.PaginationResponse;
import java.util.List;

public interface IrisEventHandingRecordService {

    TIrisEventHandingRecordDO queryByBizId(int shardingId, String bizId);

    /**
     * 保存event处理流水
     *
     * @param eventHandingRecordDO
     * @return
     */
    boolean saveRecord(TIrisEventHandingRecordDO eventHandingRecordDO);

    /**
     * 更新event处理流水
     *
     * @param eventHandingRecordDO
     * @return
     */
    boolean updateRecord(TIrisEventHandingRecordDO eventHandingRecordDO);

    TIrisEventHandingRecordDO saveHandingRecord(ActivityEventDTO eventDTO, ActivityDTO activityDTO,
            ActivityTaskDTO activityTaskDTO, List<String> handingInfoList);

    TIrisEventHandingRecordDO queryRecord(ActivityEventDTO eventDTO, ActivityDTO activityDTO,
            ActivityTaskDTO activityTaskDTO);

    TIrisEventHandingRecordDO queryRecord(IrisEventHandleContext context);

    TIrisEventHandingRecordDO saveHandingRecord(IrisEventHandleContext context, List<String> handingInfoList);

    /**
     * 查询重试消息需要的记录
     * @param shardingId
     * @param offset
     * @param limit
     * @param request
     * @return
     */
    List<TIrisEventHandingRecordDO> queryHandingRecords(int shardingId, int offset, int limit,
            EventRetryRequest request);

    /**
     * 查询处理消息
     * @param shardingId
     * @param pid
     * @param uid
     * @param taskBizId
     * @return
     */
    TIrisEventHandingRecordDO queryOneHandingRecord(int shardingId, String pid, String uid, String taskBizId);

    /**
     * 查询需要重试的记录,任务处理失败且失败次数小于3次 或者 任务处理中，处理事件大于 30分钟。只处理7天内的失败数据
     *
     * @param shardingId
     * @param offset
     * @param limit
     * @return
     */
    List<TIrisEventHandingRecordDO> queryNeedRetryRecords(int shardingId, int offset, int limit);

    /**
     * 事件处理流水日志分页查询
     * @param request
     * @return
     */
    PaginationResponse<EventHandingRecordResponse> queryEventHandingInfoPage(
            PaginationRequest<QueryEventHandingRecordPageRequest> request);
}
